// 方式一
var str = '123321311123'
var obj = str.split('').reduce((pre, next) => {
  pre[next] ? pre[next]++ : pre[next] = 1
  return pre
}, {})
var max = 0
var _name = ''
for (var i in obj) {
  if (obj[i] > max) {
    max = obj[i]
    _name = i
  }
  console.log(i);
}
console.log('出现最多的是', _name, max, '次');
// 方式二
var obj = {}
for (var i = 0; i < str.length; i++) {
  var index = str[i]
  obj[index] ? obj[index]++ : obj[index] = 1
}
console.log(obj);
function add() { }
console.log();